package com.example.sys.job.service;

import com.example.core.po.BasePo;
import com.example.core.service.BaseOuterServiceImpl;
import com.example.sys.job.po.ISysJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/***
 * 定时任务外部服务.
 */
@Service
public class SysJobOuterServiceImpl extends BaseOuterServiceImpl {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    private SysJobService sysJobService;

    @Override
    public void save(BasePo po) throws Exception {
        if (po instanceof ISysJob) {
            sysJobService.createUserJob(SysUserJobProxy.class, po, ((ISysJob) po).getRunTime());
        }
    }

    @Override
    public void update(BasePo po) throws Exception {
        if (po instanceof ISysJob) {
            sysJobService.modifyUserJob(po, ((ISysJob) po).getRunTime());
        }
    }

    @Override
    public void delete(BasePo po) throws Exception {
        if (po instanceof ISysJob) {
            sysJobService.deleteUserJob(po.getId());
        }
    }
}
